import React, { Component } from 'react'

export default class ErrorCatch extends Component {
    constructor(props){
        super(props)
    }
    state = {
        error:false,
        info:""
    }
    componentDidCatch(error, info) {
        console.log("componentDidCatch",error);
        this.setState({
            error,
            info
        })
    }
    render() {
        const {error} = this.state
        console.log("ErrorCatch");
        if(error){
            return (
                <div>ErrorCatch:{error.message}</div>
            )
        }else{
            return this.props.children
        }
    }
}
